import {
  reqGetJobList,
  reqBatchAddJob,
  reqEditJob,
  reqBatchDelJob,
} from '@/views/Custom/CompanyMng/api/PostPostingApi';
const actions = {
  // 查询全部工作信息
  async getJobList({ commit }, params) {
    let result = await reqGetJobList(params);
    commit('GETJOBLIST', result.data.jobIPage);
  },
  // 工作信息新增
  async batchAddJob({ commit }, params) {
    let result = await reqBatchAddJob(params);
    return result;
  },
  // 工作编辑
  async editJob({ commit }, params) {
    let result = await reqEditJob(params);
    return result;
  },
  // 工作删除
  async delJob({ commit }, params) {
    let result = await reqBatchDelJob(params);
    return result;
  },
};
const mutations = {
  GETJOBLIST(state, result) {
    state.jobIPage = result;
  },
};
const state = {
  jobIPage: {},
  jobList: [],
};
const getters = {
  // 工作分页查询后的包装数据
  jobIPage(state) {
    return state.jobIPage || [];
  },
  // 工作列表
  jobList(state) {
    return state.jobIPage ? state.jobIPage.records || [] : [];
  },
};
export default {
  namespaced: true,
  actions,
  mutations,
  state,
  getters,
};
